//
//  EAppImageDowloadRecv.m
//  AppRanking
//
//  Created by Gang.Wang on 12-11-26.
//  Copyright (c) 2012年 Gang.Wang. All rights reserved.
//

#import "EAppImageDowloadRecv.h"
#import "mcf.h"

@implementation EAppImageDowloadRecv

- (id) init
{
    self = [super init];
    if(self)
    {
        self.localCacheDirPath = [YPath Combine:kCache combinePath:@"appdata"];
        static BOOL created = FALSE;
        if (!created) {
            created = TRUE;
            [YPath createDirectory:self.localCacheDirPath withAttributes:nil];
        }
    }
    
    return self;
    
}

- (void) setFileName:(NSString *) fileName
{
    if ([NSString isNilOrEmpty:fileName])
    {
        return;
    }
    
    self.name = fileName;
    self.localFullPath = [YPath Combine:self.localCacheDirPath combinePath:fileName];
}

- (BOOL) bCached
{
    return [YFile fileExistsAtPath:self.localFullPath];
}

- (NSData *) data
{
    if ([self bCached])
    {
        return [NSData dataWithContentsOfFile:self.localFullPath];
    }
    
    return nil;
}


@end
